<template>
  <!-- 输入框 -->
  <header class="header">
    <h1>小黑记事本</h1>
    <input v-model="namehander" placeholder="请输入任务" class="new-todo" />
    <button @click="add" class="add">添加任务</button>
  </header>
</template>

<script>
export default {
  data() {
    return {
      namehander: "",
    };
  },
  methods: {
    add() {
      // console.log("add");
      if (this.namehander.trim() === "") {
        alert("内容不可为空");
        return;
      } else {
        this.$emit("namehander", this.namehander);
        this.namehander = "";
      }
    },
  },
};
</script>

<style></style>
